/**
 * <copyright>
 * </copyright>
 *

 */
package com.ldh.mod4j.businessdomain.businessDomainDsl.impl;

import com.ldh.mod4j.businessdomain.businessDomainDsl.Association;
import com.ldh.mod4j.businessdomain.businessDomainDsl.BusinessClass;
import com.ldh.mod4j.businessdomain.businessDomainDsl.BusinessDomainDslPackage;
import com.ldh.mod4j.businessdomain.businessDomainDsl.Multiplicity;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Association</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#getSource <em>Source</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#getSourceRoleName <em>Source Role Name</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#getSourceMultiplicity <em>Source Multiplicity</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#isBidirectional <em>Bidirectional</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#getTargetMultiplicity <em>Target Multiplicity</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#getTarget <em>Target</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#getTargetRoleName <em>Target Role Name</em>}</li>
 *   <li>{@link com.ldh.mod4j.businessdomain.businessDomainDsl.impl.AssociationImpl#isOrdered <em>Ordered</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AssociationImpl extends MinimalEObjectImpl.Container implements Association
{
  /**
   * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDescription()
   * @generated
   * @ordered
   */
  protected static final String DESCRIPTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDescription()
   * @generated
   * @ordered
   */
  protected String description = DESCRIPTION_EDEFAULT;

  /**
   * The cached value of the '{@link #getSource() <em>Source</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSource()
   * @generated
   * @ordered
   */
  protected BusinessClass source;

  /**
   * The default value of the '{@link #getSourceRoleName() <em>Source Role Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSourceRoleName()
   * @generated
   * @ordered
   */
  protected static final String SOURCE_ROLE_NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getSourceRoleName() <em>Source Role Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSourceRoleName()
   * @generated
   * @ordered
   */
  protected String sourceRoleName = SOURCE_ROLE_NAME_EDEFAULT;

  /**
   * The default value of the '{@link #getSourceMultiplicity() <em>Source Multiplicity</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSourceMultiplicity()
   * @generated
   * @ordered
   */
  protected static final Multiplicity SOURCE_MULTIPLICITY_EDEFAULT = Multiplicity.ZERO_MANY;

  /**
   * The cached value of the '{@link #getSourceMultiplicity() <em>Source Multiplicity</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSourceMultiplicity()
   * @generated
   * @ordered
   */
  protected Multiplicity sourceMultiplicity = SOURCE_MULTIPLICITY_EDEFAULT;

  /**
   * The default value of the '{@link #isBidirectional() <em>Bidirectional</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isBidirectional()
   * @generated
   * @ordered
   */
  protected static final boolean BIDIRECTIONAL_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isBidirectional() <em>Bidirectional</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isBidirectional()
   * @generated
   * @ordered
   */
  protected boolean bidirectional = BIDIRECTIONAL_EDEFAULT;

  /**
   * The default value of the '{@link #getTargetMultiplicity() <em>Target Multiplicity</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTargetMultiplicity()
   * @generated
   * @ordered
   */
  protected static final Multiplicity TARGET_MULTIPLICITY_EDEFAULT = Multiplicity.ZERO_MANY;

  /**
   * The cached value of the '{@link #getTargetMultiplicity() <em>Target Multiplicity</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTargetMultiplicity()
   * @generated
   * @ordered
   */
  protected Multiplicity targetMultiplicity = TARGET_MULTIPLICITY_EDEFAULT;

  /**
   * The cached value of the '{@link #getTarget() <em>Target</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTarget()
   * @generated
   * @ordered
   */
  protected BusinessClass target;

  /**
   * The default value of the '{@link #getTargetRoleName() <em>Target Role Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTargetRoleName()
   * @generated
   * @ordered
   */
  protected static final String TARGET_ROLE_NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getTargetRoleName() <em>Target Role Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTargetRoleName()
   * @generated
   * @ordered
   */
  protected String targetRoleName = TARGET_ROLE_NAME_EDEFAULT;

  /**
   * The default value of the '{@link #isOrdered() <em>Ordered</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isOrdered()
   * @generated
   * @ordered
   */
  protected static final boolean ORDERED_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isOrdered() <em>Ordered</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isOrdered()
   * @generated
   * @ordered
   */
  protected boolean ordered = ORDERED_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected AssociationImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return BusinessDomainDslPackage.Literals.ASSOCIATION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDescription()
  {
    return description;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDescription(String newDescription)
  {
    String oldDescription = description;
    description = newDescription;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__DESCRIPTION, oldDescription, description));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BusinessClass getSource()
  {
    if (source != null && source.eIsProxy())
    {
      InternalEObject oldSource = (InternalEObject)source;
      source = (BusinessClass)eResolveProxy(oldSource);
      if (source != oldSource)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, BusinessDomainDslPackage.ASSOCIATION__SOURCE, oldSource, source));
      }
    }
    return source;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BusinessClass basicGetSource()
  {
    return source;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSource(BusinessClass newSource)
  {
    BusinessClass oldSource = source;
    source = newSource;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__SOURCE, oldSource, source));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getSourceRoleName()
  {
    return sourceRoleName;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSourceRoleName(String newSourceRoleName)
  {
    String oldSourceRoleName = sourceRoleName;
    sourceRoleName = newSourceRoleName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__SOURCE_ROLE_NAME, oldSourceRoleName, sourceRoleName));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Multiplicity getSourceMultiplicity()
  {
    return sourceMultiplicity;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSourceMultiplicity(Multiplicity newSourceMultiplicity)
  {
    Multiplicity oldSourceMultiplicity = sourceMultiplicity;
    sourceMultiplicity = newSourceMultiplicity == null ? SOURCE_MULTIPLICITY_EDEFAULT : newSourceMultiplicity;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__SOURCE_MULTIPLICITY, oldSourceMultiplicity, sourceMultiplicity));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isBidirectional()
  {
    return bidirectional;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBidirectional(boolean newBidirectional)
  {
    boolean oldBidirectional = bidirectional;
    bidirectional = newBidirectional;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__BIDIRECTIONAL, oldBidirectional, bidirectional));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Multiplicity getTargetMultiplicity()
  {
    return targetMultiplicity;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTargetMultiplicity(Multiplicity newTargetMultiplicity)
  {
    Multiplicity oldTargetMultiplicity = targetMultiplicity;
    targetMultiplicity = newTargetMultiplicity == null ? TARGET_MULTIPLICITY_EDEFAULT : newTargetMultiplicity;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__TARGET_MULTIPLICITY, oldTargetMultiplicity, targetMultiplicity));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BusinessClass getTarget()
  {
    if (target != null && target.eIsProxy())
    {
      InternalEObject oldTarget = (InternalEObject)target;
      target = (BusinessClass)eResolveProxy(oldTarget);
      if (target != oldTarget)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, BusinessDomainDslPackage.ASSOCIATION__TARGET, oldTarget, target));
      }
    }
    return target;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BusinessClass basicGetTarget()
  {
    return target;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTarget(BusinessClass newTarget)
  {
    BusinessClass oldTarget = target;
    target = newTarget;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__TARGET, oldTarget, target));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getTargetRoleName()
  {
    return targetRoleName;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTargetRoleName(String newTargetRoleName)
  {
    String oldTargetRoleName = targetRoleName;
    targetRoleName = newTargetRoleName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__TARGET_ROLE_NAME, oldTargetRoleName, targetRoleName));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isOrdered()
  {
    return ordered;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setOrdered(boolean newOrdered)
  {
    boolean oldOrdered = ordered;
    ordered = newOrdered;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ASSOCIATION__ORDERED, oldOrdered, ordered));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case BusinessDomainDslPackage.ASSOCIATION__DESCRIPTION:
        return getDescription();
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE:
        if (resolve) return getSource();
        return basicGetSource();
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE_ROLE_NAME:
        return getSourceRoleName();
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE_MULTIPLICITY:
        return getSourceMultiplicity();
      case BusinessDomainDslPackage.ASSOCIATION__BIDIRECTIONAL:
        return isBidirectional();
      case BusinessDomainDslPackage.ASSOCIATION__TARGET_MULTIPLICITY:
        return getTargetMultiplicity();
      case BusinessDomainDslPackage.ASSOCIATION__TARGET:
        if (resolve) return getTarget();
        return basicGetTarget();
      case BusinessDomainDslPackage.ASSOCIATION__TARGET_ROLE_NAME:
        return getTargetRoleName();
      case BusinessDomainDslPackage.ASSOCIATION__ORDERED:
        return isOrdered();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case BusinessDomainDslPackage.ASSOCIATION__DESCRIPTION:
        setDescription((String)newValue);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE:
        setSource((BusinessClass)newValue);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE_ROLE_NAME:
        setSourceRoleName((String)newValue);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE_MULTIPLICITY:
        setSourceMultiplicity((Multiplicity)newValue);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__BIDIRECTIONAL:
        setBidirectional((Boolean)newValue);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET_MULTIPLICITY:
        setTargetMultiplicity((Multiplicity)newValue);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET:
        setTarget((BusinessClass)newValue);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET_ROLE_NAME:
        setTargetRoleName((String)newValue);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__ORDERED:
        setOrdered((Boolean)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case BusinessDomainDslPackage.ASSOCIATION__DESCRIPTION:
        setDescription(DESCRIPTION_EDEFAULT);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE:
        setSource((BusinessClass)null);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE_ROLE_NAME:
        setSourceRoleName(SOURCE_ROLE_NAME_EDEFAULT);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE_MULTIPLICITY:
        setSourceMultiplicity(SOURCE_MULTIPLICITY_EDEFAULT);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__BIDIRECTIONAL:
        setBidirectional(BIDIRECTIONAL_EDEFAULT);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET_MULTIPLICITY:
        setTargetMultiplicity(TARGET_MULTIPLICITY_EDEFAULT);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET:
        setTarget((BusinessClass)null);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET_ROLE_NAME:
        setTargetRoleName(TARGET_ROLE_NAME_EDEFAULT);
        return;
      case BusinessDomainDslPackage.ASSOCIATION__ORDERED:
        setOrdered(ORDERED_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case BusinessDomainDslPackage.ASSOCIATION__DESCRIPTION:
        return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE:
        return source != null;
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE_ROLE_NAME:
        return SOURCE_ROLE_NAME_EDEFAULT == null ? sourceRoleName != null : !SOURCE_ROLE_NAME_EDEFAULT.equals(sourceRoleName);
      case BusinessDomainDslPackage.ASSOCIATION__SOURCE_MULTIPLICITY:
        return sourceMultiplicity != SOURCE_MULTIPLICITY_EDEFAULT;
      case BusinessDomainDslPackage.ASSOCIATION__BIDIRECTIONAL:
        return bidirectional != BIDIRECTIONAL_EDEFAULT;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET_MULTIPLICITY:
        return targetMultiplicity != TARGET_MULTIPLICITY_EDEFAULT;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET:
        return target != null;
      case BusinessDomainDslPackage.ASSOCIATION__TARGET_ROLE_NAME:
        return TARGET_ROLE_NAME_EDEFAULT == null ? targetRoleName != null : !TARGET_ROLE_NAME_EDEFAULT.equals(targetRoleName);
      case BusinessDomainDslPackage.ASSOCIATION__ORDERED:
        return ordered != ORDERED_EDEFAULT;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (description: ");
    result.append(description);
    result.append(", sourceRoleName: ");
    result.append(sourceRoleName);
    result.append(", sourceMultiplicity: ");
    result.append(sourceMultiplicity);
    result.append(", bidirectional: ");
    result.append(bidirectional);
    result.append(", targetMultiplicity: ");
    result.append(targetMultiplicity);
    result.append(", targetRoleName: ");
    result.append(targetRoleName);
    result.append(", ordered: ");
    result.append(ordered);
    result.append(')');
    return result.toString();
  }

} //AssociationImpl
